#ifndef _PAGE_SETTINGS_H
#define _PAGE_SETTINGS_H

extern void pageReturn();
#define SETTINGS_ITEM_CNT			15
#define SETTINGS_ITEM_TYPE_SWITCH	0
#define SETTINGS_ITEM_TYPE_TEXT		1
#define SETTINGS_ITEM_TYPE_BUTTON	2

// static int settingsItemHeight[3] = {30, 60, 60};
// static int settingsScroolY = 0;

static int settingsCurrentItemNum = -1;

static lv_obj_t *stRoot;
static lv_obj_t *useNetSwitch;
static lv_obj_t *ssidInput;
static lv_obj_t *passwordInput;
static lv_obj_t *callSignInput;
static lv_obj_t *keyTypeSwitch;
static lv_obj_t *keyInvertSwitch;
static lv_obj_t *diTimeInput;
static lv_obj_t *playDiTimeInput;
static lv_obj_t *autoSendInput;
static lv_obj_t *tranCodeSwitch;
static lv_obj_t *beeFreqInput;
static lv_obj_t *beeDutyInput;

// 功能按钮
// static lv_obj_t *settingsBtnClear;
static lv_obj_t *settingsBtnCxl;
static lv_obj_t *settingsBtnReset;
static lv_obj_t *settingsBtnDone;

static lv_style_t itemBlank;
static lv_style_t itemSpac;
static lv_style_t itemTitle;
static lv_style_t swItemBody;
static lv_style_t settingsBtnFocus;
static lv_style_t settingsItemFocus;
// static lv_style_t itemInputFocus;
// static lv_style_t itemDropFocus;



typedef struct {
	lv_obj_t *obj;
	int itemType;
	int scrollY;
} settingsItemType;

static settingsItemType settingsItemGroup[SETTINGS_ITEM_CNT];

static bool newWifi = false;

static void setSwitchValue(lv_obj_t *obj, int value) {
	if(value) {
		lv_obj_add_state(obj, LV_STATE_CHECKED);
	}
	else {
		lv_obj_clear_state(obj, LV_STATE_CHECKED);
	}
}
static void setIntInput(lv_obj_t *obj, int value) {
	char tempStr[16];
	itoa(value, tempStr, 10);
	lv_textarea_set_text(obj, tempStr);
}

static void setValue() {
	loadSettings();
	LVMT;
	// 是否连接网络
	setSwitchValue(useNetSwitch, stGroup[ST_USE_NET].intValue);
	// SSID
	lv_textarea_set_text(ssidInput, stGroup[ST_SSID].strValue);
	// 密码
	lv_textarea_set_text(passwordInput, stGroup[ST_PASSWORD].strValue);
	// 呼号
	lv_textarea_set_text(callSignInput, stGroup[ST_CALL_SIGN].strValue);
	// 电键类型
	setSwitchValue(keyTypeSwitch, stGroup[ST_KEY_TYPE].intValue);
	// 是否交换电键
	setSwitchValue(keyInvertSwitch, stGroup[ST_KEY_INVERT].intValue);
	// di时长
	setIntInput(diTimeInput, stGroup[ST_DI_TIME].intValue);
	// 播放di时长
	setIntInput(playDiTimeInput, stGroup[ST_PLAY_DI_TIME].intValue);
	// 自动发送延时
	setIntInput(autoSendInput, stGroup[ST_AUTO_SEND_TIME].intValue);
	// 是否翻译电码
	setSwitchValue(tranCodeSwitch, stGroup[ST_TRAN_CODE].intValue);
	// 频率
	setIntInput(beeFreqInput, stGroup[ST_BEE_FREQ].intValue);
	// 占空比
	setIntInput(beeDutyInput, stGroup[ST_BEE_DUTY].intValue);
	LVMG;
}

static void getSwitchValue(int item, lv_obj_t *obj) {
	if(lv_obj_has_state(obj, LV_STATE_CHECKED)) {
		stGroup[item].intValue = 1;
	}
	else {
		stGroup[item].intValue = 0;
	}
}



static void getIntValue(int item, lv_obj_t *obj) {
	int tempInt = atoi(lv_textarea_get_text(obj));
	if(tempInt > 0) {
		stGroup[item].intValue = tempInt;
	}
	else {
		log("ITEM VALUE ERROR (< 0). ITEM = %d", item);
	}
}

static void getValue() {

	char *tempStr;
	getSwitchValue(ST_USE_NET, useNetSwitch);

	tempStr = lv_textarea_get_text(ssidInput);
	if(strcmp(tempStr, stGroup[ST_SSID].strValue) != 0) {
		newWifi = true;
	}
	strcpy(stGroup[ST_SSID].strValue, tempStr);

	tempStr = lv_textarea_get_text(passwordInput);
	if(strcmp(tempStr, stGroup[ST_PASSWORD].strValue)) {
		newWifi = true;
	}
	strcpy(stGroup[ST_PASSWORD].strValue, tempStr);
	strcpy(stGroup[ST_CALL_SIGN].strValue, lv_textarea_get_text(callSignInput));
	getSwitchValue(ST_KEY_TYPE, keyTypeSwitch);
	getSwitchValue(ST_KEY_INVERT, keyInvertSwitch);
	getIntValue(ST_DI_TIME, diTimeInput);
	getIntValue(ST_PLAY_DI_TIME, playDiTimeInput);
	getIntValue(ST_AUTO_SEND_TIME, autoSendInput);
	getSwitchValue(ST_TRAN_CODE, tranCodeSwitch);
	getIntValue(ST_BEE_FREQ, beeFreqInput);
	getIntValue(ST_BEE_DUTY, beeDutyInput);
	saveSettings();
}
static void inputCb(lv_event_t *e) {
	lv_event_code_t code = lv_event_get_code(e);
	// log("code = %d", code);
	lv_obj_t *ta = lv_event_get_target(e);
	// lv_obj_t *userInput = lv_event_get_user_data(e);
	if(code == LV_EVENT_CLICKED) {
		char *currentText = lv_textarea_get_text(ta);
		kbShow(ta, 0);
	}

	if(code == LV_EVENT_DEFOCUSED) {

	}
}

static void settingsCxl(lv_event_t *e) {
	log("settingsCxl");
	rotFunGoBack();
	pageReturn();
	
}

static void settingsReset(lv_event_t *e) {
	log("settings reset");
	resetSettings();
	setValue();
	
}

static void settingsSubmit(lv_event_t *e) {
	log("settingsSubmit");
	getValue();
	rotFunGoBack();
	pageReturn();
	log("page return done");
}

static void setFocus(bool t) {
	if(settingsCurrentItemNum >= 0 && settingsCurrentItemNum < SETTINGS_ITEM_CNT) {
		if(settingsItemGroup[settingsCurrentItemNum].itemType == SETTINGS_ITEM_TYPE_SWITCH || settingsItemGroup[settingsCurrentItemNum].itemType == SETTINGS_ITEM_TYPE_TEXT){
			if(t) {
				LVMT;
				lv_obj_add_style(settingsItemGroup[settingsCurrentItemNum].obj, &settingsItemFocus, 0);
				LVMG;
			}
			else {
				LVMT;
				lv_obj_remove_style(settingsItemGroup[settingsCurrentItemNum].obj, &settingsItemFocus, 0);
				LVMG;
			}
			LVMT;
			lv_obj_scroll_to_y(stRoot, settingsItemGroup[settingsCurrentItemNum].scrollY, LV_ANIM_ON);
			LVMG;
		}
		else if(settingsItemGroup[settingsCurrentItemNum].itemType == SETTINGS_ITEM_TYPE_BUTTON) {
			if(t) {
				LVMT;
				lv_obj_add_style(settingsItemGroup[settingsCurrentItemNum].obj, &settingsBtnFocus, 0);
				LVMG;
			}
			else {
				LVMT;
				lv_obj_remove_style(settingsItemGroup[settingsCurrentItemNum].obj, &settingsBtnFocus, 0);
				LVMG;
			}
		}
	}
}

// static void sendEvent(lv_event_code_t code) {
// }

static void pageSettingsRotA() {
	setFocus(false);
	if(settingsCurrentItemNum < SETTINGS_ITEM_CNT - 1) {
		settingsCurrentItemNum++;
	}
	else {
		settingsCurrentItemNum = 0;
	}
	setFocus(true);
}

static void pageSettingsRotB() {
	setFocus(false);
	if(settingsCurrentItemNum > 0) {
		settingsCurrentItemNum--;
	}
	else {
		settingsCurrentItemNum = SETTINGS_ITEM_CNT - 1;
	}
	setFocus(true);
}

static void pageSettingsRotC() {
	if(settingsItemGroup[settingsCurrentItemNum].itemType == SETTINGS_ITEM_TYPE_TEXT || settingsItemGroup[settingsCurrentItemNum].itemType == SETTINGS_ITEM_TYPE_BUTTON) {
		lv_event_send(settingsItemGroup[settingsCurrentItemNum].obj, LV_EVENT_CLICKED, NULL);
	}
	else if(settingsItemGroup[settingsCurrentItemNum].itemType == SETTINGS_ITEM_TYPE_SWITCH) {
		lv_event_send(settingsItemGroup[settingsCurrentItemNum].obj, LV_EVENT_RELEASED, NULL);
	}
	
}
static void pageSettingsRotSet() {
	rotFunSet(&pageSettingsRotA, &pageSettingsRotB, &pageSettingsRotC);
}

void pageSettingsShowFun() {
	pageSettingsRotSet();
	setValue();
}

void pageSettingsInit() {
	LVMT;
	static int stWidth = CONFIG_SCREEN_WIDTH - 60;
	static int stHeight = CONFIG_SCREEN_HEIGHT - CONFIG_TOP_STATUS_BAR_HEIGHT - 80;
	static int mWidth = CONFIG_SCREEN_WIDTH - 60;

	// 初始化样式
	lv_style_init(&itemBlank);
	lv_style_set_width(&itemBlank, mWidth);
	lv_style_set_height(&itemBlank, 10);

	lv_style_init(&itemSpac);
	lv_style_set_width(&itemSpac, 10);
	lv_style_set_height(&itemSpac, 5);

	lv_style_init(&itemTitle);
	lv_style_set_text_font(&itemTitle, CFONT);
	lv_style_set_text_align(&itemTitle, LV_TEXT_ALIGN_LEFT);
	lv_style_set_text_color(&itemTitle, LV_COLOR_BLACK);
	lv_style_set_text_opa(&itemTitle, LV_OPA_50);

	lv_style_init(&swItemBody);
	lv_style_set_width(&swItemBody, mWidth);
	lv_style_set_height(&swItemBody, LV_SIZE_CONTENT);
	lv_style_set_layout(&swItemBody, LV_LAYOUT_FLEX);
	lv_style_set_flex_flow(&swItemBody, LV_FLEX_FLOW_ROW);
	lv_style_set_flex_main_place(&swItemBody, LV_FLEX_ALIGN_SPACE_BETWEEN);
	lv_style_set_flex_cross_place(&swItemBody, LV_FLEX_ALIGN_CENTER);

	lv_style_init(&settingsItemFocus);
	lv_style_set_radius(&settingsItemFocus, 6);
	lv_style_set_border_width(&settingsItemFocus, 2);
	lv_style_set_border_color(&settingsItemFocus, LV_COLOR_BTN_BG_1);


	stRoot = lv_obj_create(pageSettings);
	lv_obj_remove_style_all(stRoot);
	lv_obj_set_size(stRoot, stWidth, stHeight);
	lv_obj_align(stRoot, LV_ALIGN_TOP_MID, 0, 20);
	lv_obj_set_style_bg_color(stRoot, LV_COLOR_WHITE, 0);
	lv_obj_set_style_bg_opa(stRoot, LV_OPA_COVER, 0);
	lv_obj_set_style_radius(stRoot, 2, 0);
	lv_obj_set_scroll_dir(stRoot, LV_DIR_VER);
	lv_obj_set_scrollbar_mode(stRoot, LV_SCROLLBAR_MODE_ON);
	lv_obj_set_style_outline_color(stRoot, LV_COLOR_WHITE, 0);
	lv_obj_set_style_outline_opa(stRoot, LV_OPA_COVER, 0);
	lv_obj_set_style_outline_width(stRoot, 12, 0);
	lv_obj_set_style_layout(stRoot, LV_LAYOUT_FLEX, 0);
	lv_obj_set_style_flex_flow(stRoot, LV_FLEX_FLOW_COLUMN, 0);
	lv_obj_set_style_flex_main_place(stRoot, LV_FLEX_ALIGN_START, 0);
	lv_obj_set_style_flex_cross_place(stRoot, LV_FLEX_ALIGN_START, 0);

	
	// ----- 使用网络 ----- //
	lv_obj_t *useNetBody = lv_obj_create(stRoot);
	lv_obj_remove_style_all(useNetBody);
	lv_obj_add_style(useNetBody, &swItemBody, 0);

	lv_label_t *useNetLabl = lv_label_create(useNetBody);
	lv_obj_add_style(useNetLabl, &itemTitle, 0);
	lv_label_set_text(useNetLabl, "是否使用网络");

	useNetSwitch = lv_switch_create(useNetBody);
	lv_obj_add_event_cb(useNetBody, inputCb, LV_EVENT_ALL, NULL);

	lv_obj_t *blank_0 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_0);
	lv_obj_add_style(blank_0, &itemBlank, 0);

	// ----- SSID ----- //
	lv_label_t *ssidLabel = lv_label_create(stRoot);
	lv_obj_add_style(ssidLabel, &itemTitle, 0);
	lv_label_set_text(ssidLabel, "WIFI SSID");

	ssidInput = lv_textarea_create(stRoot);
	lv_textarea_set_one_line(ssidInput, true);
	lv_textarea_set_placeholder_text(ssidInput, "SSID");
	lv_obj_add_event_cb(ssidInput, inputCb, LV_EVENT_ALL, ssidInput);

	lv_obj_t *blank_1 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_1);
	lv_obj_add_style(blank_1, &itemBlank, 0);

	// ----- 密码 ----- //
	lv_label_t *passwordLabel = lv_label_create(stRoot);
	lv_obj_add_style(passwordLabel, &itemTitle, 0);
	lv_label_set_text(passwordLabel, "WIFI 密码");

	passwordInput = lv_textarea_create(stRoot);
	lv_textarea_set_one_line(passwordInput, true);
	lv_textarea_set_placeholder_text(passwordInput, "Password");
	lv_obj_add_event_cb(passwordInput, inputCb, LV_EVENT_ALL, passwordInput);

	lv_obj_t *blank_2 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_2);
	lv_obj_add_style(blank_2, &itemBlank, 0);

	// ----- 呼号 ----- //
	lv_label_t *callSignLabel = lv_label_create(stRoot);
	lv_obj_add_style(callSignLabel, &itemTitle, 0);
	lv_label_set_text(callSignLabel, "呼号");

	callSignInput = lv_textarea_create(stRoot);
	lv_textarea_set_one_line(callSignInput, true);
	lv_textarea_set_placeholder_text(callSignInput, "Call Sign");
	lv_obj_add_event_cb(callSignInput, inputCb, LV_EVENT_ALL, callSignInput);

	lv_obj_t *blank_3 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_3);
	lv_obj_add_style(blank_3, &itemBlank, 0);

	// ----- 电键类型 ----- //
	lv_obj_t *keyTypBody = lv_obj_create(stRoot);
	lv_obj_remove_style_all(keyTypBody);
	lv_obj_add_style(keyTypBody, &swItemBody, 0);

	lv_label_t *keyTypLabel = lv_label_create(keyTypBody);
	lv_obj_add_style(keyTypLabel, &itemTitle, 0);
	lv_label_set_text(keyTypLabel, "使用手动电键");

	keyTypeSwitch = lv_switch_create(keyTypBody);
	lv_obj_add_event_cb(keyTypeSwitch, inputCb, LV_EVENT_ALL, NULL);

	lv_obj_t *blank_4 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_4);
	lv_obj_add_style(blank_4, &itemBlank, 0);

	// ----- 左右交换 ----- //
	lv_obj_t *keyInvertBody = lv_obj_create(stRoot);
	lv_obj_remove_style_all(keyInvertBody);
	lv_obj_add_style(keyInvertBody, &swItemBody, 0);

	lv_label_t *keyInvertLabl = lv_label_create(keyInvertBody);
	lv_obj_remove_style_all(keyInvertLabl);
	lv_obj_add_style(keyInvertLabl, &itemTitle, 0);
	lv_label_set_text(keyInvertLabl, "自动键左右互换");

	keyInvertSwitch = lv_switch_create(keyInvertBody);

	lv_obj_t *blank_5 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_5);
	lv_obj_add_style(blank_5, &itemBlank, 0);

	// ----- di时长 ----- //
	lv_label_t *diTimeLabel = lv_label_create(stRoot);
	lv_obj_remove_style_all(diTimeLabel);
	lv_obj_add_style(diTimeLabel, &itemTitle, 0);
	lv_label_set_text(diTimeLabel, "Di时长 毫秒");

	diTimeInput = lv_textarea_create(stRoot);
	lv_textarea_set_one_line(diTimeInput, true);
	lv_textarea_set_placeholder_text(diTimeInput, "Di Time");
	lv_obj_add_event_cb(diTimeInput, inputCb, LV_EVENT_ALL, diTimeInput);

	lv_obj_t *blank_6 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_6);
	lv_obj_add_style(blank_6, &itemBlank, 0);

	// ----- 播放di时长 ----- //
	lv_label_t *playDiTimeLabel = lv_label_create(stRoot);
	lv_obj_remove_style_all(playDiTimeLabel);
	lv_obj_add_style(playDiTimeLabel, &itemTitle, 0);
	lv_label_set_text(playDiTimeLabel, "播放Di时长 毫秒");

	playDiTimeInput = lv_textarea_create(stRoot);
	lv_textarea_set_one_line(playDiTimeInput, true);
	lv_textarea_set_placeholder_text(playDiTimeInput, "Play Di Time");
	lv_obj_add_event_cb(playDiTimeInput, inputCb, LV_EVENT_ALL, playDiTimeInput);

	lv_obj_t *blank_7 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_7);
	lv_obj_add_style(blank_7, &itemBlank, 0);

	// ----- 自动发送延时 ----- //
	lv_label_t *autoSendLabel = lv_label_create(stRoot);
	lv_obj_remove_style_all(autoSendLabel);
	lv_obj_add_style(autoSendLabel, &itemTitle, 0);
	lv_label_set_text(autoSendLabel, "自动发送延时");

	autoSendInput = lv_textarea_create(stRoot);
	lv_textarea_set_one_line(autoSendInput, true);
	lv_textarea_set_placeholder_text(autoSendInput, "Auto Send Delay");
	lv_obj_add_event_cb(autoSendInput, inputCb, LV_EVENT_ALL, autoSendInput);

	lv_obj_t *blank_8 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_8);
	lv_obj_add_style(blank_8, &itemBlank, 0);

	// ----- 翻译电码 ----- //
	lv_obj_t *tranCodeBody = lv_obj_create(stRoot);
	lv_obj_remove_style_all(tranCodeBody);
	lv_obj_add_style(tranCodeBody, &swItemBody, 0);

	lv_label_t *tranCodeLabl = lv_label_create(tranCodeBody);
	lv_obj_remove_style_all(tranCodeLabl);
	lv_obj_add_style(tranCodeLabl, &itemTitle, 0);
	lv_label_set_text(tranCodeLabl, "是否翻译电码");

	tranCodeSwitch = lv_switch_create(tranCodeBody);

	lv_obj_t *blank_9 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_9);
	lv_obj_add_style(blank_9, &itemBlank, 0);

	// ----- 声音频率 ----- //
	lv_label_t *beeFreqLabel = lv_label_create(stRoot);
	lv_obj_remove_style_all(beeFreqLabel);
	lv_obj_add_style(beeFreqLabel, &itemTitle, 0);
	lv_label_set_text(beeFreqLabel, "音频频率");

	beeFreqInput = lv_textarea_create(stRoot);
	lv_textarea_set_one_line(beeFreqInput, true);
	lv_textarea_set_placeholder_text(beeFreqInput, "Bee Freq");
	lv_obj_add_event_cb(beeFreqInput, inputCb, LV_EVENT_ALL, beeFreqInput);

	lv_obj_t *blank_10 = lv_obj_create(stRoot);
	lv_obj_remove_style_all(blank_10);
	lv_obj_add_style(blank_10, &itemBlank, 0);

	// ----- 声音占空比 ----- //
	lv_label_t *beeDutyLabel = lv_label_create(stRoot);
	lv_obj_remove_style_all(beeDutyLabel);
	lv_obj_add_style(beeDutyLabel, &itemTitle, 0);
	lv_label_set_text(beeDutyLabel, "音频占空比");

	beeDutyInput = lv_textarea_create(stRoot);
	lv_textarea_set_one_line(beeDutyInput, true);
	lv_textarea_set_placeholder_text(beeDutyInput, "Bee Duty");
	lv_obj_add_event_cb(beeDutyInput, inputCb, LV_EVENT_ALL, beeDutyInput);

	
	lv_obj_t *bottom = lv_obj_create(pageSettings);
	lv_obj_remove_style_all(bottom);
	lv_obj_set_size(bottom, CONFIG_SCREEN_WIDTH, 40);
	lv_obj_set_layout(bottom, LV_LAYOUT_FLEX);
	lv_obj_set_flex_flow(bottom, LV_FLEX_FLOW_ROW);
	lv_obj_set_style_flex_main_place(bottom, LV_FLEX_ALIGN_SPACE_AROUND, 0);
	lv_obj_set_style_flex_cross_place(bottom, LV_FLEX_ALIGN_CENTER, 0);
	lv_obj_align(bottom, LV_ALIGN_TOP_MID, 0, stHeight + 40);


	static lv_style_t settingsBtnBody;
	lv_style_init(&settingsBtnBody);
	lv_style_set_width(&settingsBtnBody, 65);
	lv_style_set_height(&settingsBtnBody, 35);
	lv_style_set_radius(&settingsBtnBody, 6);
	lv_style_set_bg_color(&settingsBtnBody, LV_COLOR_MAIN_BG_4);
	lv_style_set_bg_opa(&settingsBtnBody, LV_OPA_COVER);
	lv_style_set_text_color(&settingsBtnBody, LV_COLOR_WHITE);

	lv_style_init(&settingsBtnFocus);
	lv_style_set_bg_color(&settingsBtnFocus, LV_COLOR_BTN_BG_1);


	// settingsBtnClear = lv_obj_create(bottom);
	// lv_obj_remove_style_all(settingsBtnClear);
	// lv_obj_add_style(settingsBtnClear, &settingsBtnBody, 0);
	// lv_label_t *settingsBtnClearLabel = lv_label_create(settingsBtnClear);
	// lv_obj_center(settingsBtnClearLabel);
	// lv_obj_set_style_text_font(settingsBtnClearLabel, CFONT, 0);
	// lv_label_set_text(settingsBtnClearLabel, "清除");
	// lv_obj_add_event_cb(settingsBtnClear, eraseNvs, LV_EVENT_ALL, NULL);

	settingsBtnCxl = lv_obj_create(bottom);
	lv_obj_remove_style_all(settingsBtnCxl);
	lv_obj_add_style(settingsBtnCxl, &settingsBtnBody, 0);
	lv_label_t *settingsBtnCxlLabel = lv_label_create(settingsBtnCxl);
	lv_obj_center(settingsBtnCxlLabel);
	lv_obj_set_style_text_font(settingsBtnCxlLabel, CFONT, 0);
	lv_label_set_text(settingsBtnCxlLabel, "取消");
	lv_obj_add_event_cb(settingsBtnCxl, settingsCxl, LV_EVENT_CLICKED, NULL);

	settingsBtnReset = lv_obj_create(bottom);
	lv_obj_remove_style_all(settingsBtnReset);
	lv_obj_add_style(settingsBtnReset, &settingsBtnBody, 0);
	lv_label_t *settingsBtnResetLabel = lv_label_create(settingsBtnReset);
	lv_obj_center(settingsBtnResetLabel);
	lv_obj_set_style_text_font(settingsBtnResetLabel, CFONT, 0);
	lv_label_set_text(settingsBtnResetLabel, "重置");
	lv_obj_add_event_cb(settingsBtnReset, settingsReset, LV_EVENT_CLICKED, NULL);

	settingsBtnDone = lv_obj_create(bottom);
	lv_obj_remove_style_all(settingsBtnDone);
	lv_obj_add_style(settingsBtnDone, &settingsBtnBody, 0);
	lv_label_t *settingsBtnDoneLabel = lv_label_create(settingsBtnDone);
	lv_obj_center(settingsBtnDoneLabel);
	lv_obj_set_style_text_font(settingsBtnDoneLabel, CFONT, 0);
	lv_label_set_text(settingsBtnDoneLabel, "确定");
	lv_obj_add_event_cb(settingsBtnDone, settingsSubmit, LV_EVENT_CLICKED, NULL);
	LVMG;
	int i = 0;
	settingsItemGroup[i++] = (settingsItemType){useNetSwitch, SETTINGS_ITEM_TYPE_SWITCH, 0};
	settingsItemGroup[i++] = (settingsItemType){ssidInput, SETTINGS_ITEM_TYPE_TEXT, 0};
	settingsItemGroup[i++] = (settingsItemType){passwordInput, SETTINGS_ITEM_TYPE_TEXT, 50};
	settingsItemGroup[i++] = (settingsItemType){callSignInput, SETTINGS_ITEM_TYPE_TEXT, 100};
	settingsItemGroup[i++] = (settingsItemType){keyTypeSwitch, SETTINGS_ITEM_TYPE_SWITCH, 160};
	settingsItemGroup[i++] = (settingsItemType){keyInvertSwitch, SETTINGS_ITEM_TYPE_SWITCH, 220};
	settingsItemGroup[i++] = (settingsItemType){diTimeInput, SETTINGS_ITEM_TYPE_TEXT, 280};
	settingsItemGroup[i++] = (settingsItemType){playDiTimeInput, SETTINGS_ITEM_TYPE_TEXT, 340};
	settingsItemGroup[i++] = (settingsItemType){autoSendInput, SETTINGS_ITEM_TYPE_TEXT, 400};
	settingsItemGroup[i++] = (settingsItemType){tranCodeSwitch, SETTINGS_ITEM_TYPE_SWITCH, 460};
	settingsItemGroup[i++] = (settingsItemType){beeFreqInput, SETTINGS_ITEM_TYPE_TEXT, 520};
	settingsItemGroup[i++] = (settingsItemType){beeDutyInput, SETTINGS_ITEM_TYPE_TEXT, 580};
	// settingsItemGroup[i++] = (settingsItemType){settingsBtnClear, SETTINGS_ITEM_TYPE_BUTTON, 0};
	settingsItemGroup[i++] = (settingsItemType){settingsBtnCxl, SETTINGS_ITEM_TYPE_BUTTON, 0};
	settingsItemGroup[i++] = (settingsItemType){settingsBtnReset, SETTINGS_ITEM_TYPE_BUTTON, 0};
	settingsItemGroup[i++] = (settingsItemType){settingsBtnDone, SETTINGS_ITEM_TYPE_BUTTON, 0};
}

#endif